#include <string>

#include <gtest/gtest.h>

#include "echo.pb.h"

#define protected public
#include "../src/base_channel.h"
#undef protected

using namespace std;
using namespace google::protobuf;
using namespace testing;
using namespace skeleton;
using namespace skeleton::test;

/*获得EchoService中指定方法的描述符*/
static const MethodDescriptor&  getMethodDescriptor(const string &methodName)
{
  static class MyService:public EchoService
  {
  public:
    virtual const ServiceDescriptor* GetDescriptor(){return EchoService::GetDescriptor();}
  }service;
  return *service.GetDescriptor()->FindMethodByName(methodName);
}

/*测试案例：测试序列化请求*/
TEST(BaseChannelTest, SerializeRequestTest)
{
  EchoParameter param;
  param.set_msg("Hello,this is client");
  BaseChannel channel;
  const MethodDescriptor &descriptor = getMethodDescriptor("echo");
  string requestData = channel.serializeRequest(descriptor, param);
}
